package com.java.car;

import com.java.database.entity.Applicat;
import com.java.database.mapper.ApplicatMapper;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

public class Entrance {
    public static void main(String[] args) throws IOException {
        // 读取mybatis-config文件
        InputStream inputStream = Resources.getResourceAsStream("mybatis-config.xml");
        // 创建sqlsessionFactory
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
        // 拿到会话对象
        SqlSession sqlSession = sqlSessionFactory.openSession();

        ApplicatMapper mapper = sqlSession.getMapper(ApplicatMapper.class);
        List<Applicat> blogs = mapper.selectAll();
        sqlSession.close();
    }
}
